using IdentityServer4Center;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// IdentityServer 4配置模式
builder.Services.AddIdentityServer()
    .AddDeveloperSigningCredential()
    .AddInMemoryClients(Config.GetClients()) //Client模式
    .AddInMemoryApiScopes(Config.ApiScopes) //作用域
    .AddInMemoryApiResources(Config.GetApiResources()); //资源
// 添加认证和授权服务
builder.Services.AddAuthentication();
builder.Services.AddAuthorization();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthentication();
app.UseAuthorization();

app.UseIdentityServer(); //使用Id4
app.Run();